public class TwoArrayExercise6_2 {
    public static void main(String[] args) {
        int[][] yangHui = new int[10][];

        for (int i = 0; i < yangHui.length; i++) {
            /*
            当i=0， yangHui[0]的长度是1
            当i=1， yangHui[0]的长度是2
                   yangHui[i]的长度是i+1
             */
            yangHui[i] = new int[i+1];

            yangHui[i][0] = 1;//每一行的第1个元素
            // yangHui[i][yangHui[i].length-1] = 1;
            yangHui[i][i] = 1;//每一行的最后1个元素

            //中间的元素，j=1排除第1列，j<yangHui[i].length-1排除最后1列
            for(int j=1; j<yangHui[i].length-1; j++){
                yangHui[i][j] = yangHui[i-1][j-1] + yangHui[i-1][j];

            }

         }

        //打印
        for (int i = 0; i < yangHui.length; i++) {
            for (int j = 0; j < yangHui[i].length; j++) {
                System.out.print(yangHui[i][j]+"\t");
            }
            System.out.println();
        }

    }
}
